package cn.zero.api.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import cn.zero.config.AppConstants;
import cn.zero.service.UserService;

@RestController
public class IndexAPIController extends BaseAPIController {

	private Logger logger = LoggerFactory.getLogger(getClass());
	
	@Autowired
	private UserService userService;
	
	@PostMapping("/signUp")
	public Object signUp(@RequestParam("mobile") String mobile, @RequestParam("password") String password,
			@RequestParam(value = "invitorId", required = false) Long invitorId) {
		logger.info("mobile: {}, password: {}", mobile, password);
		userService.create(mobile, password, invitorId);
		return success();
	}
	
	@PostMapping("/left")
	public Object left() {
		return success((int)AppConstants.BALANCE + "");
	}
	
}
